<?php

namespace app\admin\controller;


class Contri extends Base
{
    //投稿列表
    public function all()
    {
        //查询出投稿列表按时间倒序排序
        $contris = model('Contri')->with('member')->order('create_time', 'asc')->paginate(10);
        //定义模板变量
        $viewData = [
            'contris' => $contris
        ];
        //渲染
        $this->assign($viewData);
        return view();
    }

    //投稿删除
    public function del()
    {
        //从数据库里查询出投稿id，先查询后删除
        $contriInfo = model('Contri')->find(input('post.id'));
        $result = $contriInfo->delete();
        if ($result){
            //删除成功
            $this->success('删除成功','admin/contri/all');
        }else{
            $this->error('删除失败');
        }
    }
}
